﻿using System.Data.Entity.ModelConfiguration;
using System.Security.Cryptography.X509Certificates;
using ModelLayer;

namespace DataLayer.Configurations
{
    public class OrderConfig : EntityTypeConfiguration<Order>
    {

        public OrderConfig()
        {
            HasKey(x => x.OrderId);

            HasOptional(x => x.User).WithMany(x => x.Orders).HasForeignKey(x => x.UserId);

            ToTable("Order");
        }
    }

    public class OrderDetailConfig : EntityTypeConfiguration<OrderDetail>
    {

        public OrderDetailConfig()
        {
            HasKey(x => x.OrderDetailId);
            HasOptional(x => x.Order).WithMany(x => x.OrderDetails).HasForeignKey(x => x.OrderId);
            HasOptional(x => x.Product).WithMany(x => x.OrderDetails).HasForeignKey(x => x.ProductId);

            ToTable("OrderDetail");
        }
    }
}
